{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "36105\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>t</th>\n",
       "      <th>sym</th>\n",
       "      <th>px</th>\n",
       "      <th>qty</th>\n",
       "      <th>b1sz</th>\n",
       "      <th>b1px</th>\n",
       "      <th>a1px</th>\n",
       "      <th>a1sz</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>36100</th>\n",
       "      <td>2020-04-06D13:24:57.600581000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2740000</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "      <td>2740000</td>\n",
       "      <td>2745000</td>\n",
       "      <td>180</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36101</th>\n",
       "      <td>2020-04-06D13:24:57.664715000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2740000</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "      <td>2740000</td>\n",
       "      <td>2745000</td>\n",
       "      <td>179</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36102</th>\n",
       "      <td>2020-04-06D13:24:57.667594000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2740000</td>\n",
       "      <td>6</td>\n",
       "      <td>17</td>\n",
       "      <td>2740000</td>\n",
       "      <td>2745000</td>\n",
       "      <td>179</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36103</th>\n",
       "      <td>2020-04-06D13:24:58.488651000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2740000</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>2740000</td>\n",
       "      <td>2745000</td>\n",
       "      <td>179</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36104</th>\n",
       "      <td>2020-04-06D13:24:59.783237000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2740000</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>2740000</td>\n",
       "      <td>2745000</td>\n",
       "      <td>179</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   t   sym       px  qty  b1sz     b1px  \\\n",
       "36100  2020-04-06D13:24:57.600581000  2330  2740000    0    23  2740000   \n",
       "36101  2020-04-06D13:24:57.664715000  2330  2740000    0    23  2740000   \n",
       "36102  2020-04-06D13:24:57.667594000  2330  2740000    6    17  2740000   \n",
       "36103  2020-04-06D13:24:58.488651000  2330  2740000    0    17  2740000   \n",
       "36104  2020-04-06D13:24:59.783237000  2330  2740000    0    17  2740000   \n",
       "\n",
       "          a1px  a1sz  \n",
       "36100  2745000   180  \n",
       "36101  2745000   179  \n",
       "36102  2745000   179  \n",
       "36103  2745000   179  \n",
       "36104  2745000   179  "
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import re\n",
    "import math\n",
    "import matplotlib.pyplot as plt\n",
    "df = pd.read_csv(\"2330-0406.csv\")\n",
    "tmp = 2730000\n",
    "for index,row in df.iterrows():\n",
    "    if row['px'] != 0:\n",
    "        tmp = row['px']\n",
    "    else:\n",
    "        df.loc[index, 'px'] = tmp\n",
    "print(len(df))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 337,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#Calculate VOI\n",
    "def delta_vtb(rows):\n",
    "    row0 ,row1 = rows.iloc[0], rows.iloc[1]\n",
    "    if np.less(row1[\"b1px\"], row0[\"b1px\"]):\n",
    "        return 0\n",
    "    if np.equal(row1[\"b1px\"], row0[\"b1px\"]):\n",
    "        return np.subtract(row1[\"b1sz\"], row0[\"b1sz\"])\n",
    "    return row1[\"b1sz\"]\n",
    "\n",
    "def delta_vta(rows):\n",
    "    row0 ,row1 = rows.iloc[0], rows.iloc[1]\n",
    "    if np.less(row1[\"a1px\"], row0[\"a1px\"]):\n",
    "        return row1[\"a1sz\"]\n",
    "    if np.equal(row1[\"a1px\"], row0[\"a1px\"]):\n",
    "        return np.subtract(row1[\"a1sz\"], row0[\"a1sz\"])\n",
    "    return 0\n",
    "\n",
    "def chunker(seq):\n",
    "    return (seq.iloc[pos:pos + 2] for pos in range(0, len(seq)-1))\n",
    "\n",
    "VOI = list()\n",
    "\n",
    "for group in chunker(df):\n",
    "    VOI.append(delta_vtb(group) - delta_vta(group))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 338,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "36104"
      ]
     },
     "execution_count": 338,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(VOI)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 339,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Calculate LOG_RETURN\n",
    "def log_return(rows):\n",
    "    px0 ,px1 = rows.iloc[0][\"px\"], rows.iloc[1][\"px\"]\n",
    "    return (np.log(px1))-(np.log(px0))\n",
    "\n",
    "LOG = list()\n",
    "count = 0\n",
    "for group in chunker(df):\n",
    "    LOG.append(log_return(group))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 340,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "36104"
      ]
     },
     "execution_count": 340,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(LOG)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 341,
   "metadata": {},
   "outputs": [],
   "source": [
    "VOI_np = np.array(VOI)\n",
    "\n",
    "unique, counts = np.unique(VOI_np, return_counts=True)\n",
    "VOI_count = dict(zip(unique, counts))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 342,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAD4CAYAAAAO9oqkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAASxElEQVR4nO3df6zddX3H8edrVPC3LXDHWNvsdtq4FLMp3kAXjdlkKQWNZYmakkU619k/rJtuJlo0WReQRLNNJtlgqdJRDAEJamgGih1iyBL5cVHkp9grqG1T6NVWNCP+KL73x/l0Hi/3tveec3tPy30+kpPz/b4/n+85n/PJ6Xnd749zmqpCkjS//dagByBJGjzDQJJkGEiSDANJEoaBJAlYMOgB9OrUU0+t4eHhQQ9Dko4r99133w+ramhi/bgNg+HhYUZHRwc9DEk6riT5/mR1DxNJkgwDSZJhIEnCMJAkYRhIkjAMJEkYBpIkDANJEtMIgyRbk+xL8tAkbR9MUklObetJckWSsSQPJDmzq++6JDvbbV1X/fVJHmzbXJEks/XiJEnTM509g2uA1ROLSZYCq4AfdJXPA5a32wbgqtb3ZGAzcDZwFrA5yaK2zVXAe7q2e85zScea4U23DHoI0qw6YhhU1Z3A/kmaLgc+BHT/V2lrgGur4y5gYZLTgXOBHVW1v6oOADuA1a3t5VV1V3X+y7VrgQv6e0mSpJnq6ZxBkjXAnqr61oSmxcCurvXdrXa4+u5J6lM974Yko0lGx8fHexm6JGkSMw6DJC8GPgL8w+wP5/CqaktVjVTVyNDQc350T5LUo172DF4JLAO+leR7wBLgG0l+B9gDLO3qu6TVDldfMkldkj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qp6rq2ar6FfBpfn0oaF7PU5IX0AmC66rqC6080PfUfAsDf/ZiCklekuRlh5aBVcBDdOZnXeu2Drh5MCM85kw1L9uBi9oVICuBp7t2/eedCce2/5zOewo687Q2yUlJltE5OXrPXI9vEJIEuBp4tKo+2dU02PdUVc2rG3A+8B3gu8BHBz2eY+UG/D7wrXZ7+NDcAKfQubJhJ/DfwMmDHusA5uZ6Ooc4fknneO36qeYFCJ0r1r4LPAiMDHr8A56nz7Z5eKB9qJ3e1f+jbZ4eA84b9PjncJ7eSOcQ0APA/e12/qDfU/4chSRp3h0mkiRNwjCQJBkGkiTDQJKEYSBJwjCQJGEYSJKA/wMkZcut72RgKQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(range(len(VOI_count)), list(VOI_count.values()), align='center')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 343,
   "metadata": {},
   "outputs": [],
   "source": [
    "LOG_np = np.array(LOG)\n",
    "\n",
    "unique, counts = np.unique(LOG_np, return_counts=True)\n",
    "LOG_count = dict(zip(unique, counts))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 344,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAD4CAYAAAAO9oqkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAARVElEQVR4nO3cXaxdZZ3H8e/PFhzjy1DkTNO0ZcpoM5NqYsET6EQzYSCWghfFhCFwIR3DWBPbRBMvrN6UUUlwMsqEBElqaCwTx9r4MjRapzYMieMF0AN2gJZhOFNLaFPaI+VFYwZS/M/Ffqo7nfOy23POP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V1BXA9sKFdbpgTqnM9dDZfE70PeA+wEjgKfG1muzO1krwD+D7w2ap6rXvdbDu2o4y1L8d2rofBnPoZjKo60l6PAz+kc5lsNjvWrsOeuh57fIb7M22q6lhVvVlVvwO+ySw6tkkuoPPh+O2q+kErz8pjO9pY+3Vs53oYzJmfwUjy9nZTiiRvB1YDT4+/1XlvJ7Cuza8DHpzBvkyrUx+MzceYJcc2SYD7gWeq6utdq2bdsR1rrP06tnP6aSKA9pjWP/GHn8G4c4a7NC2S/BmdswHo/AzJv8ymsSb5DnA1nZ/7PQZsBv4V2AFcCjwP3FxV5/2N1zHGejWdywgFHAI+1XVN/byV5MPAfwBPAb9r5S/SuZY+q47tOGO9lT4c2zkfBpIkLxNJkjAMJEkYBpIkDANJEoaBJAnDQJKEYSBJAv4PVW/IUFvzducAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(range(len(LOG_count)), list(LOG_count.values()), align='center')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 345,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                            OLS Regression Results                            \n",
      "==============================================================================\n",
      "Dep. Variable:                      y   R-squared:                       0.005\n",
      "Model:                            OLS   Adj. R-squared:                  0.005\n",
      "Method:                 Least Squares   F-statistic:                     189.8\n",
      "Date:                Mon, 14 Sep 2020   Prob (F-statistic):           4.56e-43\n",
      "Time:                        21:52:28   Log-Likelihood:             2.2194e+05\n",
      "No. Observations:               36104   AIC:                        -4.439e+05\n",
      "Df Residuals:                   36102   BIC:                        -4.439e+05\n",
      "Df Model:                           1                                         \n",
      "Covariance Type:            nonrobust                                         \n",
      "==============================================================================\n",
      "                 coef    std err          t      P>|t|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "const       2.515e-08   2.72e-06      0.009      0.993   -5.31e-06    5.36e-06\n",
      "X           3.331e-06   2.42e-07     13.776      0.000    2.86e-06    3.81e-06\n",
      "==============================================================================\n",
      "Omnibus:                     6196.713   Durbin-Watson:                   2.223\n",
      "Prob(Omnibus):                  0.000   Jarque-Bera (JB):           144023.276\n",
      "Skew:                          -0.008   Prob(JB):                         0.00\n",
      "Kurtosis:                      12.785   Cond. No.                         11.3\n",
      "==============================================================================\n",
      "\n",
      "Warnings:\n",
      "[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n"
     ]
    }
   ],
   "source": [
    "#逐筆比較\n",
    "import statsmodels.api as sm\n",
    "series_dict={'X':VOI,'y':LOG}\n",
    "cal=pd.DataFrame(series_dict)\n",
    "X=cal[['X']]\n",
    "y=cal[['y']]\n",
    "x = sm.add_constant(X)\n",
    "ols_results = sm.OLS(y, x).fit()\n",
    "print(ols_results.summary())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 346,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAD4CAYAAADCb7BPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAYrElEQVR4nO3df5CdVZ3n8fcn3Z3YskASaDMxCZOsZNzCRUFvBSx3t5gFkoxaJuMyEgtn4gxDxkXKsdxhNogWLEIJpLZ0prScisBOYNCEYTW0vzYTQP6YrSWmM4D8GDO0GE33RGhJwF8oJHz3j3s63r65t3+c+/T90f15Vd3q5znPec4999yn76fv86sVEZiZmU3VnFZ3wMzMOpMDxMzMsjhAzMwsiwPEzMyyOEDMzCxLd6s7UKTTTz89li9f3upumJl1lH379v0kIvqmut6MCpDly5czMDDQ6m6YmXUUST/MWc+7sMzMLIsDxMzMsjhAzMwsiwPEzMyyOEDMzCyLA8TMzLI4QMz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JUNAxdUlT9UeKeboN64jJL0QeDdwIWRdsxSf1wYp3wmG288ZgVJPZTD4+6I+EoqflbS4og4lHZRPZfKZ9N4vQN4j6R3Aq8BTgH+ivJuu+70LaPy9Y+OzZCkbuBU4Plxn6HVB3j8GHOw6wC/OYj+LsYe7PtOKl8I/IDyAfQFaXphq/s+DWOxFngK6KsqfxNjD6I/Q/lAcneaXsFvDia/qdWvownjNCtfd8XrF3An8Nmq8i2MPYh+a5qu+Xs10x+U/+gcPYj+94w9iH5lmv4wYw+i3zNRu/4G0r6+SfmMkUHgl8AfA0TEYUmfAvamejdExOHWdHFafY5ySOxO384ejogPRcSTku6hHC5HgQ9HxDEASVdRPputC7gjIp5sTdebJyKOzsbXXeEdwB8Cj0t6NJV9HLgZuEfS5ZTPbnxfWlbz92qW+e/Adkk3Ao8At6fy24G7JA0ChymHyLh8KxMzM8vis7DMzCyLA8TMzLI4QMzMLIsDxMzMsjhAzMwsiwPEzMyyOEDMzCzL/wfcO9+Si6OLWwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(VOI,LOG)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 347,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>t</th>\n",
       "      <th>sym</th>\n",
       "      <th>px</th>\n",
       "      <th>qty</th>\n",
       "      <th>b1sz</th>\n",
       "      <th>b1px</th>\n",
       "      <th>a1px</th>\n",
       "      <th>a1sz</th>\n",
       "      <th>VOI</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-04-06D09:05:00.192751000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2730000</td>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "      <td>2730000</td>\n",
       "      <td>2735000</td>\n",
       "      <td>386</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-04-06D09:05:00.349290000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2730000</td>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "      <td>2730000</td>\n",
       "      <td>2735000</td>\n",
       "      <td>386</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-04-06D09:05:00.411350000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2730000</td>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "      <td>2730000</td>\n",
       "      <td>2735000</td>\n",
       "      <td>386</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-04-06D09:05:00.421660000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2730000</td>\n",
       "      <td>0</td>\n",
       "      <td>27</td>\n",
       "      <td>2730000</td>\n",
       "      <td>2735000</td>\n",
       "      <td>386</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-04-06D09:05:01.110040000</td>\n",
       "      <td>2330</td>\n",
       "      <td>2730000</td>\n",
       "      <td>0</td>\n",
       "      <td>27</td>\n",
       "      <td>2730000</td>\n",
       "      <td>2735000</td>\n",
       "      <td>386</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               t   sym       px  qty  b1sz     b1px     a1px  \\\n",
       "0  2020-04-06D09:05:00.192751000  2330  2730000    0    25  2730000  2735000   \n",
       "1  2020-04-06D09:05:00.349290000  2330  2730000    0    25  2730000  2735000   \n",
       "2  2020-04-06D09:05:00.411350000  2330  2730000    0    25  2730000  2735000   \n",
       "3  2020-04-06D09:05:00.421660000  2330  2730000    0    27  2730000  2735000   \n",
       "4  2020-04-06D09:05:01.110040000  2330  2730000    0    27  2730000  2735000   \n",
       "\n",
       "   a1sz  VOI  \n",
       "0   386    0  \n",
       "1   386    0  \n",
       "2   386    0  \n",
       "3   386    2  \n",
       "4   386    0  "
      ]
     },
     "execution_count": 347,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "VOI = [0] + VOI\n",
    "df['VOI'] = VOI\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 348,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "start = '2020-04-06D09:05:00'\n",
    "start = datetime.strptime(start, \"%Y-%m-%dD%H:%M:%S\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 349,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "from datetime import datetime\n",
    "from datetime import timedelta\n",
    "\n",
    "\n",
    "def thresh_hold_voi(sec:int,df):\n",
    "    l = []\n",
    "    start = '2020-04-06D09:05:00'\n",
    "    end = '2020-04-06D13:25:00'\n",
    "    start = datetime.strptime(start, \"%Y-%m-%dD%H:%M:%S\")\n",
    "    end = datetime.strptime(end, \"%Y-%m-%dD%H:%M:%S\")\n",
    "    while start <= end :\n",
    "        l.append(start)\n",
    "        start = start + timedelta(hours=0, minutes=0, seconds=sec)\n",
    "    time_stamp = l\n",
    "    time_iter = iter(time_stamp)\n",
    "    x = next(time_iter)\n",
    "    x = next(time_iter)\n",
    "\n",
    "    voi_cum = []\n",
    "    voi_res = []\n",
    "    log_cal = []\n",
    "    log_res = []\n",
    "\n",
    "    for index,row in df.iterrows():\n",
    "        row['t'] = row['t'][:-3]\n",
    "        t = datetime.strptime(row['t'], \"%Y-%m-%dD%H:%M:%S.%f\")\n",
    "        if True:\n",
    "            if t <= x:\n",
    "                voi_cum.append(row['VOI'])\n",
    "            elif t > x:\n",
    "                voi_res.append(sum(voi_cum))\n",
    "                voi_cum=[]\n",
    "                log_cal.append(row['px'])\n",
    "                x = next(time_iter)\n",
    "        else:\n",
    "            voi_res.append(sum(voi_cum))\n",
    "            break\n",
    "    for i in range (1,len(log_cal)):\n",
    "        log_res.append((np.log(log_cal[i]))-(np.log(log_cal[i-1])))\n",
    "    return voi_res, log_res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 360,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAD4CAYAAAAZ1BptAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAZMElEQVR4nO3df5DcdZ3n8ecrk0l2YIX8YC4XkuBEjFzhucuPvsiVP8otIInWronKSdzdM96y5iylXGtruQrHenB41gqU692WllsROAMlwi6rMG6tFwPIbu3dETORAAGNGWK8zGyAkQRYNUIS3vdHfyZ02v5MT09/u6d78npUdeXbn++nv9/3fL89eU1/v9/PtxURmJmZ1TJrugswM7PO5ZAwM7Msh4SZmWU5JMzMLMshYWZmWbOnu4AinXXWWTEwMDDdZZiZdZWdO3f+NCL6a82bUSExMDDA0NDQdJdhZtZVJP0kN8+Hm8zMLMshYWZmWQ4JMzPLckiYmVmWQ8LMzLIcEmZmluWQMDOzLIeEmZllOSTMzCzLIWFmZlkOCTMzy3JImJlZlkPCzMyyHBJmZpblkDAzsyyHhJmZZTkkzMw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JHwF+G7g0/aK0bZs1YKLt1BaSeikHxNci4hsAEfFsxfzJ7tfCRcRo+vc5Sd+kfJjmWUmLI+JgOhzx3HTURjm4vj++rTplmyWNbqNR4F1V7Q+3orBO+b3suk8Sk3AZ8MOIOPHRS1K/pJ40/QZgBbAvfcx8SdIl6TzGh4H7W1FU1THf9wHjVzIMAuslzZW0PNX2PWAHsELS8vSX2PrUt+i61gD/CXhvRPyion3at1mVtmyPnPSz3gb8ICL+vKK90f3aitpOl/S68WnKJz13pxrGr77ZwGv7aRD4sMouAV6sOOTSCid9su+EbVah0W20FVglaX46TLYqtRWqo34vizj73UkP4KvAx6raPgA8CewCvg/8TsW8EuU36dPAF0mj0FtQ153AE8DjlN+AiyvmXZfWv4eKKxIoX2HxozTvuhbVNUz5GOuu9PjLTtlmNWpt+faYYN1vp3wo4vGKbfWeqezXFtT2BspXBT2W9tl1qX0h8CCwF3gAWJDaBXwp1fYEUGphbacDzwNnVrRNyzajHFQHgaOUj9lfNZVtRPkcwXB6/IcW1dUxv5e+LYeZmWXNxMNNZmZWEIeEmZllOSTMzCzLIWFmZlkOCTMzy3JImJlZlkPCzMyy/j+4hl7BJTx/XwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "voi_30, LOG_30 =thresh_hold_voi(30,df)\n",
    "voi_30 = voi_30[:-1]\n",
    "plt.scatter(voi_30,LOG_30)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 359,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                            OLS Regression Results                            \n",
      "==============================================================================\n",
      "Dep. Variable:                      y   R-squared:                       0.001\n",
      "Model:                            OLS   Adj. R-squared:                 -0.001\n",
      "Method:                 Least Squares   F-statistic:                    0.5518\n",
      "Date:                Mon, 14 Sep 2020   Prob (F-statistic):              0.458\n",
      "Time:                        22:06:02   Log-Likelihood:                 2722.3\n",
      "No. Observations:                 518   AIC:                            -5441.\n",
      "Df Residuals:                     516   BIC:                            -5432.\n",
      "Df Model:                           1                                         \n",
      "Covariance Type:            nonrobust                                         \n",
      "==============================================================================\n",
      "                 coef    std err          t      P>|t|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "const       6.249e-06   5.56e-05      0.112      0.911      -0.000       0.000\n",
      "X           3.166e-07   4.26e-07      0.743      0.458   -5.21e-07    1.15e-06\n",
      "==============================================================================\n",
      "Omnibus:                        8.894   Durbin-Watson:                   2.984\n",
      "Prob(Omnibus):                  0.012   Jarque-Bera (JB):                5.632\n",
      "Skew:                          -0.077   Prob(JB):                       0.0598\n",
      "Kurtosis:                       2.513   Cond. No.                         131.\n",
      "==============================================================================\n",
      "\n",
      "Warnings:\n",
      "[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n"
     ]
    }
   ],
   "source": [
    "#delta t = 30s\n",
    "series_dict={'X':voi_30,'y':LOG_30}\n",
    "cal=pd.DataFrame(series_dict)\n",
    "X=cal[['X']]\n",
    "y=cal[['y']]\n",
    "x = sm.add_constant(X)\n",
    "ols_results = sm.OLS(y, x).fit()\n",
    "print(ols_results.summary())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
